package com.xiaoyu.lanling.media.selector.matisse

import android.content.Context
import com.xiaoyu.media.matisse.MimeType
import com.xiaoyu.media.matisse.filter.Filter
import com.xiaoyu.media.matisse.internal.entity.IncapableCause
import com.xiaoyu.media.matisse.internal.entity.Item

class VideoDurationFilter(val types: Set<MimeType>, val duration: Long, val inCapableMessage: String) : Filter() {

    override fun constraintTypes(): Set<MimeType> {
        return types
    }

    override fun filter(context: Context, item: Item): IncapableCause? {
        if (item.duration > duration)
            return IncapableCause(IncapableCause.TOAST, inCapableMessage)
        else return null
    }
}